package com.bawei.module_vehicle.ui

import com.bawei.lib_common.base.BaseResponse
import com.bawei.module_vehicle.http.CarApiService
import com.bawei.module_vehicle.http.CarModule
import com.bawei.module_vehicle.model.CarModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.flowOn
import javax.inject.Inject

class CarRepository @Inject constructor(
    @CarModule.CommonMainApi
    private val carApi: CarApiService
) {
    // 根据 id 搜索车辆（返回单个 CarModel 封装在 BaseResponse）
    fun searchVehicleById(id: Long): Flow<BaseResponse<CarModel>> = flow {
        val response = carApi.getVehicleById(id)
        emit(response)
    }.flowOn(Dispatchers.IO)
}